package com.ruibang.glass.material.controller.bcp;

import com.ruibang.glass.material.domain.req.bcp.BcpProductsInfoReq;
import com.ruibang.glass.material.entity.bcp.MaterialBcpProductsInInfo;
import com.ruibang.glass.material.entity.bgjj.MaterialBGJJManagementInventory;
import com.ruibang.glass.material.entity.ycl.MaterialManagementInventory;
import com.ruibang.glass.material.service.bcp.MaterialBcpProductsInInfoService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * 半成品入库管理 前端控制器
 * </p>
 *
 * @author mameng
 * @since 2024-02-05
 */
@RestController
@RequestMapping("/api/material/bcp/product/info")
@Api(value = "半成品入库管理", tags = {"半成品入库管理"})
public class MaterialBcpProductInfoController {


    @Autowired
    private MaterialBcpProductsInInfoService materialBcpProductsInService;

    @PostMapping("/list")
    @ApiOperation(value = "半成品入库管理列表查询", response = ResultBody.class)
    public ResultBody getPageList(@RequestBody BcpProductsInfoReq bcpProductsInfoReq) {
        return ResultBody.success(materialBcpProductsInService.getPage(bcpProductsInfoReq));
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增半成品入库管理", response = ResultBody.class)
    public ResultBody addMaterialBcpProductsInInfo(@RequestBody List<MaterialBcpProductsInInfo> materialBcpProductsInInfoList) {
        materialBcpProductsInService.addMaterialBcpProductsInInfoList(materialBcpProductsInInfoList);
        return ResultBody.success();
    }

    @PostMapping("/update")
    @ApiOperation(value = "更新审批", response = ResultBody.class)
    public ResultBody updateMaterialBcpProductsInInfo(@RequestBody MaterialBcpProductsInInfo materialBcpProductsInInfo) {
        materialBcpProductsInService.updateMaterialBcpProductsInInfo(materialBcpProductsInInfo);
        return ResultBody.success();
    }


    @GetMapping("/getOne/{id}")
    @ApiOperation(value = "查询", response = ResultBody.class)
    public ResultBody getMaterialBcpProductsInInfo(@PathVariable("id") String id) {
        MaterialBcpProductsInInfo byId = materialBcpProductsInService.getMaterialBcpProductsInInfoById(id);
        return ResultBody.success(byId);
    }

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "详情", response = ResultBody.class)
    public ResultBody getById(@PathVariable("id") String id) {
        MaterialBcpProductsInInfo byId = materialBcpProductsInService.getById(id);
        return ResultBody.success(byId);
    }

    @PostMapping("/removeByIds")
    @ApiOperation(value = "删除", response = ResultBody.class)
    public ResultBody removeByIds(@RequestBody MaterialBcpProductsInInfo materialBcpProductsInInfo) {
        materialBcpProductsInService.removeByIds(materialBcpProductsInInfo.getIds());
        return ResultBody.success();
    }

    @PostMapping("/updateInHouse")
    @ApiOperation(value = "完成入库", response = ResultBody.class)
    public ResultBody updateInHouse(@RequestBody MaterialBcpProductsInInfo materialManagement) {
        materialBcpProductsInService.updateInHouse(materialManagement);
        return ResultBody.success();
    }

    @GetMapping("getINNumber")
    @ApiOperation(value = "成品入库单号", response = ResultBody.class)
    public ResultBody getINNumber() {
        return ResultBody.success(materialBcpProductsInService.getINNumber());
    }




}
